﻿using System.IO;
using System.Xml.Linq;
using Comdiv.QWeb.Serialization;
using Comdiv.QWeb.Serialization.BxlParser;

namespace Comdiv.QWeb {
	public static class MyBxl {
		public static XElement ParseFile(string filename, bool nolexdata = false, bool safeattributes = false) {
			return new BxlXmlParser(nolexdata, safeattributes).Parse(File.ReadAllText(filename), Path.GetFileName(filename));
		}

		public static XElement Parse(string code, bool nolexdata = false, bool safeattributes = false) {
			return new BxlXmlParser(nolexdata, safeattributes).Parse(code, "code.bxl");
		}

		public static string Convert(XElement data) {
			return new XmlToBxlConverter().Convert(data);
		}

		public static string ConvertFile(string filename) {
			return new XmlToBxlConverter().Convert(XElement.Load(filename));
		}
	}
}